package com.spa.infrastructure.mapper;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spa.application.command.admin.CityAddCommand;
import com.spa.application.command.admin.CityConfigTravelCommand;
import com.spa.application.dto.admin.CityDTO;
import com.spa.application.dto.admin.CityExportDTO;
import com.spa.domain.entity.CitiesServed;
import com.spa.infrastructure.enums.dict.CityStatusEnum;
import com.spa.infrastructure.repository.condition.CitiesServedCondition;
import com.spa.infrastructure.repository.po.CitiesServedPO;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 开通城市管理(CitiesServed) 映射结构类
 *
 * @author makejava
 * @since 2024-01-12 15:53:02
 */
@Mapper
@MapperConfig(unmappedTargetPolicy = ReportingPolicy.WARN)
public interface CitiesServedMapperStruct {

	CitiesServedMapperStruct INSTANCE = Mappers.getMapper(CitiesServedMapperStruct.class);
	
	Page<CitiesServed> po2Entity4Page(Page<CitiesServedPO> po);
	
	List<CitiesServed> po2Entity4List(List<CitiesServedPO> po);
	
	CitiesServed po2Entity(CitiesServedPO po);

	List<CityDTO> entity2CityDto4List(List<CitiesServed> citiesServedList);

	List<CityExportDTO> entity2CityExportDto4List(List<CitiesServed> citiesServedList);

	@Mapping(source = "status", target = "status", qualifiedByName = "int2Str")
	CityExportDTO entity2CityExportDto(CitiesServed citiesServed);

	CityDTO entity2CityDto(CitiesServed citiesServed);

	CitiesServedPO command2Po(CityAddCommand command);

	CitiesServedPO command2Po(CityConfigTravelCommand command);

	CitiesServedCondition command2Condition(CityAddCommand command);

	@Named("int2Enum")
	default CityStatusEnum int2Enum(int status) {
		return CityStatusEnum.byCode(status);
	}

	@Named("int2Str")
	default String int2Str(int status) {
		return CityStatusEnum.byCode(status).getDesc();
	}
}
